package com.lagou.edu.config;

public class RateLimitConfig {
    private String ip;
    int capacity = 10; //桶的最大容量，即能装载 Token 的最大数量
    int refillTokens = 1;
    int refillDurationSeconds = 1;

    public String getKey() {
        return ip + "-" + capacity + "-" + refillTokens + "-" + refillDurationSeconds;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public int getCapacity() {
        return capacity;
    }

    public void setCapacity(int capacity) {
        this.capacity = capacity;
    }

    public int getRefillTokens() {
        return refillTokens;
    }

    public void setRefillTokens(int refillTokens) {
        this.refillTokens = refillTokens;
    }

    public int getRefillDurationSeconds() {
        return refillDurationSeconds;
    }

    public void setRefillDurationSeconds(int refillDurationSeconds) {
        this.refillDurationSeconds = refillDurationSeconds;
    }

    @Override
    public String toString() {
        return "RateLimitConfig{" +
                "ip='" + ip + '\'' +
                ", capacity=" + capacity +
                ", refillTokens=" + refillTokens +
                ", refillDurationSeconds=" + refillDurationSeconds +
                '}';
    }
}
